package rest.common;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import model.Theme;
import model.Topbar;

@Path("/topbar")
public class TopbarResource {
	
	@Context
	private ServletContext  servletContext;
	
	@GET
	@Produces({MediaType.APPLICATION_JSON})
	public Topbar getTopbar() {
		Topbar topbar = new Topbar();
		topbar.setWebName(servletContext.getInitParameter("webAppName"));
		topbar.setLogImg("");
		topbar.setLoginUser("张雨舟");
		topbar.setDefaultTheme(servletContext.getInitParameter("defaultTheme"));
		
		List<Theme> themes = new ArrayList<Theme>();
		Theme theme = new Theme("Default", "default");
		themes.add(theme);
		theme = new Theme("Classic", "classic");
		themes.add(theme);
		theme = new Theme("Cerulean", "cerulean");
		themes.add(theme);
		theme = new Theme("Cyborg", "cyborg");
		themes.add(theme);
		theme = new Theme("Redy", "redy");
		themes.add(theme);
		theme = new Theme("Journal", "journal");
		themes.add(theme);
		theme = new Theme("Simplex", "simplex");
		themes.add(theme);
		theme = new Theme("Slate", "slate");
		themes.add(theme);
		theme = new Theme("Spacelab", "spacelab");
		themes.add(theme);
		theme = new Theme("United", "united");
		themes.add(theme);
		topbar.setThemes(themes);
		return topbar;
	}

	@GET
	@Path("/themes")
	@Produces( { MediaType.APPLICATION_JSON })
	public List<Theme> findAll() {
		List<Theme> themes = new ArrayList<Theme>();
		Theme theme = new Theme("Default", "default");
		themes.add(theme);
		theme = new Theme("Classic", "classic");
		themes.add(theme);
		theme = new Theme("Cerulean", "cerulean");
		themes.add(theme);
		theme = new Theme("Cyborg", "cyborg");
		themes.add(theme);
		theme = new Theme("Redy", "redy");
		themes.add(theme);
		theme = new Theme("Journal", "journal");
		themes.add(theme);
		theme = new Theme("Simplex", "simplex");
		themes.add(theme);
		theme = new Theme("Slate", "slate");
		themes.add(theme);
		theme = new Theme("Spacelab", "spacelab");
		themes.add(theme);
		theme = new Theme("United", "united");
		themes.add(theme);
		return themes;
	}
}
